home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_asm
/
disasm
/
apendtxt.bas
next >
Wrap
BASIC Source File
|
1988-06-03
|
5KB
|
118 lines
1000 '*************************************************************************
1010 '*************************************************************************
1020 '
1030 'APPEND, Version 1.0
1040 'Author: J. Crone
1050 'Date: 1-25-82
1060 '
1070 'Copyright 1982 by Personal Computer Age. All rights reserved.
1080 'This program is published for the personal use of readers of Personal
1090 'Compurter Age. Commercial use is prohibited.
1100 '
1110 '*************************************************************************
1120 '*************************************************************************
1130 '
1140 '
1150 'Initialize.
1160 DEFINT A-Z:KEY OFF:CLS
1170 CLOSE 'any oper files.
1180 'Set the following variable equal to a number slightly larger than
1190 'the length of the average line in the files you will be appending.
1200 AVG.LINE.LEN=140
1210 ARRAY.SIZE = FRE(0)/(AVG.LINE.LEN + 1)
1220 DIM TRANSFER$(ARRAY.SIZE)
1230 '
1240 '
1250 'Display title and instructins.
1260 DATA " PERSONAL COMPUTER AGE - File Combining Utility "
1270 DATA "Enter file names as requested. An output file is required"
1280 DATA "and may be a new file or an existing file. Up to eight"
1290 DATA "append files may be entered. After completion the output"
1300 DATA "file will contain all files in the order listed. Type"
1310 DATA "'\' as the last entry to start execution."
1320 DATA "Note: this utility works on text files only."
1330 COLOR 0,7:READ TEXT$:LOCATE 3,(40-(LEN(TEXT$)/2)):PRINT TEXT$:COLOR 7,0
1340 COL = 10:FOR I = 5 TO 9:LOCATE I,COL:READ TEXT$:PRINT TEXT$:NEXT I
1345 PRINT:PRINT:LOCATE ,COL:READ TEXT$:PRINT TEXT$
1350 '
1360 '
1370 LOCATE 25,25:COLOR 8,1:INPUT "Press Return Key to continue!",I$:COLOR 0,1
1380 'Get output file name.
1390 ON ERROR GOTO 1920
1400 I = 1
1410 CLS:LOCATE 3,31:COLOR 8,1:PRINT "Diskette Directory"
1420 PRINT:PRINT:FILES:COLOR 0,1
1430 COL=25:LOCATE 13,COL:LINE INPUT; "Output File Name - ",FILE.NAME$(I)
1440 IF INSTR(FILE.NAME$(I),"\") THEN GOTO 1830 'Abort.
1450 OPEN FILE.NAME$(I) FOR APPEND AS #1
1460 '
1470 '
1480 'Get append file names.
1490 FOR I = 2 TO 9
1500 LOCATE 25,1:PRINT SPC(79)
1510 LOCATE 12 + I,COL: PRINT USING "Append File Name _## - ";(I-1);
1520 LINE INPUT FILE.NAME$(I)
1530 IF INSTR(FILE.NAME$(I),"\") THEN GOTO 1610 'done.
1540 'Test for good file specification.
1550 OPEN FILE.NAME$(I) FOR INPUT AS #2:CLOSE #2
1560 NEXT I
1570 IF I = 10 THEN I = 9
1580 ON ERROR GOTO 0
1590 '
1600 '
1610 'Do the job.
1620 LOCATE 25,1:PRINT SPC(79)
1630 FOR J = 2 TO (I-1)
1640 LOCATE 25,1:PRINT SPC(79);
1650 COLOR 23,0:LOCATE 25.25:PRINT "Appending ",FILE.NAME$(J);:COLOR 7,0
1660 OPEN FILE.NAME$(J) FOR INPUT AS #2
1670 ERASE TRANSFER$ 'Garbage collection, the fast way.
1680 DIM TRANSFER$(ARRAY.SIZE)
1690 FOR K = 0 TO ARRAY.SIZE 'Read lines from input file.
1700 IF EOF(2) THEN GOTO 1730
1710 LINE INPUT #2,TRANSFER$(K)
1720 NEXT K
1730 IF K = 0 THEN GOTO 1780
1740 FOR L = 0 TO (K-1) 'Write lines to output file.
1750 PRINT #1, TRANSFER$(L)
1760 NEXT L
1770 GOTO 1670
1780 CLOSE #2 'Input file.
1790 NEXT J
1800 CLOSE #1 'Output file.
1810 '
1820 '
1830 'More work to do?
1840 LOCATE 25,1:PRINT SPC(79);:LOCATE 24,15
1850 LINE INPUT; "Job Complete. More files to transfer? (Y/N) ";RESPONSE$
1860 IF LEFT$(RESPONSE$,1) = "Y" OR LEFT$(RESPONSE$,1) = "y" THEN GOTO 1890
1870 CLS:SYSTEM 'system 'Job complete, return to DOS.
1880 'Erase screen and go again.
1890 FOR I = 11 TO 25: LOCATE I,1:PRINT SPC(78);: NEXT I
1900 GOTO 1380
1910 '
1920 'Trap common errors.
1930 BEEP
1940 MSG52$ = "Too many files open, Allocate more buffers and try again."
1950 MSG53$ = "That file does not exist. Please reenter."
1960 MSG64$ = "Incorrect file specification. Please reenter."
1970 MSG67$ = "Bad file name or too many files. Reenter or use a new disk."
1980 MSG70$ = "Remove write protect tab from disk."
1990 MSG71$ = "Put a disk in the drive and close the door."
2000 LOCATE 25,1:PRINT SPC(79);:LOCATE 25,1
2010 TRAP = 0
2020 IF ERR = 52 THEN PRINT MSG52$;:CLOSE: END
2030 IF ERR = 53 THEN PRINT MSG53$;: TRAP = 1
2040 IF ERR = 64 THEN PRINT MSG54$;: TRAP = 1
2050 IF ERR = 67 THEN PRINT MSG67$;: TRAP = 1
2060 IF ERR = 70 THEN PRINT MSG70$;: TRAP = 1
2070 IF ERR = 71 THEN PRINT MSG71$;: TRAP = 1
2080 IF TRAP = 0 THEN GOTO 2120
2090 'Found the problem. Go back and try again.
2100 LOCATE 12 + I,1:PRINT SPC(79);
2110 IF I = 1 THEN RESUME 1430 ELSE RESUME 1510
2120 'Not a common error. Let the system handle it.
2130 ON ERROR GOTO 0:CLOSE
2140 SAV.ERR = ERR:RESUME 2150
2150 ERROR SAV.ERR:END